API Documentation
Public Member Functions | Public Attributes | List of all members
nkMaths::Rectangle Class Reference

Represents a 2D rectangle. More...

Public Member Functions

 Rectangle ()=default
 
 Rectangle (float x, float y, float width, float height)
 
bool pointInside (Point point) const
 
Rectangle operator+ (const Rectangle &other)
 

Public Attributes

union {
   float   _x
 
   float   x
 
}; 
 The x coordinate of the origin, accessible through different names. Starts as the bottom left.
 
union {
   float   _y
 
   float   y
 
}; 
 The y coordinate of the origin, accessible through different names. Starts as the bottom left.
 
union {
   float   _width
 
   float   width
 
}; 
 The full width of the rectangle, accessible through different names.
 
union {
   float   _height
 
   float   height
 
}; 
 The full height of the rectangle, accessible through different names.
 

Detailed Description

Represents a 2D rectangle.

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

nkMaths::Rectangle::Rectangle ( )
default

Default constructor. All members will be set to 0.

◆ Rectangle() [2/2]

nkMaths::Rectangle::Rectangle ( float  x,
float  y,
float  width,
float  height 
)

Constructor.

Parameters
xThe x component of the origin.
yThe y component of the origin.
widthThe rectangle width.
heightThe rectangle height.

Member Function Documentation

◆ pointInside()

bool nkMaths::Rectangle::pointInside ( Point  point) const

Checks if a point is inside the rectangle.

Parameters
pointThe point to check against the rectangle.
Returns
If the point is inside (true) or not (false).

◆ operator+()

Rectangle nkMaths::Rectangle::operator+ ( const Rectangle other)

Overrides adding rectangles. Conceptually, sum components from the other rectangle with the calling one (origin + other.origin, dimensions + other.dimensions).

Parameters
otherThe rectangle to add.

The documentation for this class was generated from the following file: